package com.shimi.erp.utils;

import com.shimi.erp.domain.PageHelper;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

public class CommonUtil {

    public static Pageable getPageable (PageHelper pageHelper){

        Sort.Order order = new Sort.Order(Sort.Direction.fromString(pageHelper.getDirection()), pageHelper.getSort());
        Sort sort = new Sort(order);
        Pageable pageable = new PageRequest(pageHelper.getPage(),pageHelper.getSize(), sort);

        return pageable;
    }
}
